<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="address=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="browsermode" content="application" />
    <meta name="x5-page-mode" content="app" />
    <title>认证中心</title>
    <meta charset="utf-8" />
    <link href="../css/main.css?rev=@@hash" rel="stylesheet" />
    <style>
        body{
            width: 3.75rem;
            background-color: #3276fe;
        }
        .layer_dialog .layer_dialog_ft::after, .layer_dialog .layer_dialog_hd:after {
            border-top: 0px solid white;
        }
        .layer_dialog .layer_dialog_hd {
            padding: .05rem 0;
        }
        .identiList{
            padding-top: .1rem;
            border-top: .005rem solid #689AFF;
        }
        .identiList li{
            width: 3.43rem;
            height: .8rem;
            line-height: .8rem;
            background:#F9FAFB;
            border-radius: .07rem;
            margin: 0 auto .1rem;
        }
        .identiList a {
            display: block;
            width: 3.43rem;
            height: .8rem;
        }
        .identiList .identiIcon, 
        .identiList .identiName,
        .identiStatus,
        .rightArrow{
            display: inline-block;
        }
        .identiList .identiIcon{
            float: left;
            width: .8rem;
            height: .8rem;
        }
        .identiList .identiName{
            float: left;
            font-family: PingFang-SC-Heavy;
            font-weight: bold;
            font-size: .14rem;
            color: #202020;
            margin-left: .1rem;           
        }
        .identiStatus{
            font-family: PingFang-SC-Medium;
            font-size: .12rem;
            color: #3276fe;
        }
        .rightArrow{
            width: .24rem;
            height: .24rem;
            margin-bottom: -.07rem;
            margin-right: .1rem;
        }
        .identiRight{
            float: right;
        }
        .submitBtn{
            width: 3.43rem;
            line-height: .45rem;
            text-align: center;
            margin: .5rem auto .2rem;
            background: #ffb624;
            border-radius: .45rem;
            box-shadow: 0 0 0 #fff;
            position: static;
        }
        header{
            width: 100%;
            height: .44rem;
            line-height: .44rem;
            position: fixed;
            left: 0;
            top: 0;
            background: #3276fe;
            border-bottom: .005rem solid #1656D6;;
        }
        header img,
        header span{
             display: inline-block;
             float: left;
        }
        header .backIcon{
            width: .24rem;
            height: .24rem;
            margin: .1rem 0 0 .16rem;
        }
        header .pageTitle{
            width: 80%;
            text-align: center;
            color: #fff;
            font-size: .17rem;
        }
        header .refresh{
            float: right;
            margin-right: .16rem;
            font-size: .14rem;
            color: #fff;
        }        
    </style>
</head>
<body>
    <!-- 蒙版 -->
    <div class="layer_load">
        <div class="layer_mask"></div>
        <div class="layer_load_icon icon-loading"></div>
    </div>
    <!--<header>
            <a href="../index.html"><img class="backIcon" src="../img/backIcon.png" /></a>
            <span class="pageTitle">认证材料</span>
            <span class="refresh"></span>
    </header>    -->
    <ul class="identiList">
        <li class="identiItem">
            <a class="checkItem" href="javascript:;"><!--href="checkInf.html"-->  
                <img class="identiIcon" src="../img/identi1.png" />
                <span class="identiName">身份信息</span>
                <div class="identiRight">
                    <span class="identiStatus"></span>
                    <img class="rightArrow" src="../img/gogogo.png" />
                </div>
            </a>
        </li> 
        <li class="identiItem">
            <a class="checkItem" id="fundlist" href="javascript:;">
                <img class="identiIcon" src="../img/identi4.png" />
                <span class="identiName">住房公积金(额度更高)</span>
                <div class="identiRight">
                    <span class="identiStatus"></span>
                    <img class="rightArrow" src="../img/gogogo.png" />
                </div>
            </a>    
        </li>    
        <!--<li class="identiItem">
            <a class="checkItem" id="alipay" href="javascript:;">
                <img class="identiIcon" src="../img/identi3.png" />
                <span class="identiName">支付宝认证</span>
                <div class="identiRight">
                    <span class="identiStatus"></span>
                    <img class="rightArrow" src="../images/gogogo.png" />
                </div>
            </a>    
        </li>             -->
        <li class="identiItem">
            <a class="checkItem" id="carrier" href="javascript:;">
                <img class="identiIcon" src="../img/identi2.png" />
                <span class="identiName">手机运营商</span>
                <div class="identiRight">
                    <span class="identiStatus"></span>
                    <img class="rightArrow" src="../img/gogogo.png" />
                </div>
            </a>
        </li> 
        <li class="identiItem">
            <a class="checkItem" href="javascript:;"> 
                <img class="identiIcon" src="../img/identi6.png" />
                <span class="identiName">补充信息</span>
                <div class="identiRight">
                    <span class="identiStatus"></span>
                    <img class="rightArrow" src="../img/gogogo.png" />
                </div>
            </a>
        </li>      
        <li class="identiItem">
            <a class="checkItem" href="javascript:;">  
                <img class="identiIcon" src="../img/identi5.png" />
                <span class="identiName">绑定银行卡</span>
                <div class="identiRight">
                    <span class="identiStatus"></span>
                    <img class="rightArrow" src="../img/gogogo.png" />
                </div>
            </a>
        </li>                         
    </ul>
    <div class="cellSubBtn">
        <h6 class="submitBtn">提交</h6>
    </div>

    <!-- 脚本 -->
    <script src="../lib/zepto.min.js?rev=@@hash"></script>
    <script src="../js/main.js?rev=@@hash"></script>
    <script>
        (function(global,userUtil,layer){      
            //$("body").height(document.documentElement.clientHeight);
            var mobile=localStorage.getItem("moblie");
            var sessionId=userUtil.sid();
            var orderNo=localStorage.getItem("orderNo");
            var realName=localStorage.getItem("realName");
            var idCard=localStorage.getItem("idCard");
            var progress;
            var indexNum;
            var mainUrl = "https://api.51datakey.com/h5/importV3/index.html#/";////魔蝎认证      
            var backUrl = "http://zch5.pushunjinfuchina.com/src/trust/identification.html";///认证完成返回的URL页面
            var fromMywallet;
            var carrier = mainUrl+"carrier?apiKey=f87af4aace244af89fc6049e4519f3e3&showTitleBar=NO&themeColor=3276FE&backUrl="+backUrl+"&userId="+localStorage.getItem("userID");
            var alipay = mainUrl+"alipay?apiKey=f87af4aace244af89fc6049e4519f3e3&showTitleBar=NO&themeColor=3276FE&backUrl="+backUrl+"&userId="+localStorage.getItem("userID");
            var fundlist = mainUrl+"fundlist?apiKey=f87af4aace244af89fc6049e4519f3e3&showTitleBar=NO&themeColor=3276FE&backUrl="+backUrl+"&userId="+localStorage.getItem("userID");
            if(global.query){
                fromMywallet = global.query;
            }
            
            $(".cells_title img ").click(function(){
                var tips_a={
                    title: "提 示",
                    content: "请务必填写您的真实信息，错误信息会影响您的审核结果。",
                    btnText: "我知道了",
                    btnEvent: function () { }
                }
                layer.alert(tips_a);
            })


            //获取认证进展状态
            function getProgress(){
                $.ajax({
                    url: global.localUrl + "wallet/orders/getCompletion",  
                    type: "post",
                    data: JSON.stringify({"sessionId": sessionId,"userUuid" : localStorage.getItem("userID") }),
                    contentType: 'application/json;charset=utf-8',
                    success: function (re) {
                        if (1 == re.code) {
                            var _data=re.data;
                            idCard=_data.idCardNo;
                            realName=_data.realName;
                            progress = [_data.userProgress,_data.accumulationFundProgress,_data.operatorProgress,_data.detailProgress,_data.bankCardProgress];
                            for(var i=0;i<progress.length;i++){
                                if(progress[i] == 2){
                                    $('.identiStatus').eq(i).text("已认证");
                                }else if(progress[i] == 0 || progress[i] == null||progress[i] == 1){
                                    $('.identiStatus').eq(i).text("未认证");
                                }else if(progress[i] == 3){
                                    $('.identiStatus').eq(i).text("认证中");
                                }
                            }   
                            indexNum = (_data.userProgress==2?1:0)+(_data.operatorProgress==2?1:0)+(_data.detailProgress==2?1:0)+(_data.bankCardProgress==2?1:0)+1;
                            if(indexNum==5){
                                $(".submitBtn").click(function(){
                                    $(".submitBtn").off("click");

                                     $.ajax({
                                        url: global.localUrl + "wallet/orders/submit",
                                        type: "post",
                                        data: JSON.stringify({"sessionId": sessionId,"orderNo":orderNo,"userUuid" : localStorage.getItem("userID") }),
                                        contentType: 'application/json;charset=utf-8',
                                        success: function (re) {
                                            if (1 == re.code) {
                                                layer.tips("提交审核成功");
                                                setTimeout(function(){
                                                    //window.location.href=global.localUrl+'index.html';
                                                    window.location.href='../user/myWallet.html';
                                                }, 2000);

                                            }else if(1046 == re.code){
                                                layer.tips("请设置交易密码");
                                                setTimeout(function(){
                                                    //window.location.href=global.localUrl+'trust/setPassword.html';
                                                    window.location.href='../trust/setPassword.html';
                                                }, 2000);
                                            }else{
                                                layer.tips(re.message);
                                            }
                                        },
                                        error: function () {
                                            layer.tips(global.netError);
                                        }
                                    });
                                })
                            }else{
                                if(fromMywallet){
                                    $(".submitBtn").click(function(){
                                        layer.tips("保存成功");
                                        setTimeout(function(){
                                            //window.location.href=global.localUrl+"index.html";
                                            window.location.href="../index.html";
                                        },2000);
                                    })
                                    return;

                                }
                                $(".submitBtn").click(function(){
                                    $(".submitBtn").off("click");
                                });
                            }

                        }else{
                            layer.tips(re.message);
                        }
                    },
                    error: function () {
                        layer.tips(global.netError);
                    }
                });
            }
 		// 点击认证每项认证步骤
             $('.identiItem').on('click',function(){
             	var step = $(this).index()+1;
                var _data={
                   "orderNo": localStorage.getItem("orderNo"),
                   "step": step
                };
              	for(var i=0;i<progress.length;i++){
                    if(progress[i] != 2){
		                $.ajax({
		                   url: global.localUrl + "wallet/orders/orderStep",
		                   type: "post",
		                   data: JSON.stringify(_data),
		                   contentType: 'application/json;charset=utf-8',
		                   success: function (re) {
		                   	//for(var i=0;i<progress.length;i++){
		                        if (1 == re.code) {
					               switch(step){
						               	case 1: window.location.href="checkInf.html";break;
						               	case 2: window.location.href=fundlist;break;
						               	//case 3: window.location.href=alipay;break;
						               	case 3: window.location.href=carrier;break;
						               	case 4: window.location.href="personInf.html";break;
						               	case 5: window.location.href="bindCard.html";break;
					               }		                       	
		                       }else{
		                           layer.tips(re.message);
		                       }
		                      //}
		                   },
		                   error: function () {
		                       layer.tips(global.netError);
		                   }
		                });                       	
                    } else {
                  		$(this).off('click');
                    }
				} 	
                       	
           })

            getProgress();
            //iOS刷新获取认证状态
            var u = navigator.userAgent;
            var ios = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
            if(ios){
	           var getgetProgressTime = setInterval(function(){
	            	    if(indexNum != 5){
	            	    	getProgress();
	            	    }else{
	            	    	clearInterval(getgetProgressTime);
	            	    }
	            },5000);
            }
        })(global,userUtil,layer)
    </script>
</body>
</html>